import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import PassboxView from '@/views/passbox/PassboxView.vue'
import BiliHistoryView from '@/views/bili/BiliHistoryView.vue'

const router = createRouter({
  history:
    import.meta.env.MODE === 'uni'
      ? createWebHashHistory()
      : createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
      redirect: '/passbox',
      children: [
        {
          path: '/passbox',
          name: 'passbox',
          component: PassboxView,
        },
        {
          path: '/bilihistory',
          name: 'bilihistory',
          component: BiliHistoryView,
        },
      ],
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue'),
    },
  ],
})

export default router
